//function 函数名（参数：类型）：函数返回值类型{}
function fn(): void { }
function fn1(name: string): string {
    return name
}

console.log(fn1('杰哥哥'))

function fn2(name: string): number {
    return 1
}

//箭头函数
let fn3 = (name: string): boolean => {
    return true
}

//形参默认值
let fn4 = (name: string, age: number = 18): void => {
    console.log(name, age)
}
fn4('123', 2)
fn4('123')
//可选参数
let fn5 = (name: string, age: number = 18, sex?: boolean): void => {
    console.log(name, age)
}
fn5('123', 22, true)
fn5('123', 22)
//剩余参数
let fn6 = (...res: number[]): number => {
    let count: number = 0
    for (let i: number = 0; i < res.length; i++) {
        count += res[i]
    }
    return count
}
console.log(fn6(1, 2, 3, 4, 5));
